//
//  FPInreviewController.m
//  FinanceProject
//
//  Created by 陈显摆 on 2025/1/24.
//

#import "FPInreviewController.h"
#import "FPBankCardModel.h"

@interface FPInreviewController ()

@property (weak, nonatomic) IBOutlet UIView *backView;

@property (weak, nonatomic) IBOutlet UILabel *descripLab;

@property (weak, nonatomic) IBOutlet UILabel *tipLab1;
@property (weak, nonatomic) IBOutlet UILabel *tipLab2;
@property (weak, nonatomic) IBOutlet UILabel *tipLab3;
@property (weak, nonatomic) IBOutlet UILabel *tipLab4;
@property (weak, nonatomic) IBOutlet UILabel *tipLab5;
@property (weak, nonatomic) IBOutlet UILabel *tipLab6;
@property (weak, nonatomic) IBOutlet UIImageView *bankLogoImgView;
@property (weak, nonatomic) IBOutlet UIView *lineView;


@end

@implementation FPInreviewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 删除控制器
    NSMutableArray *marr = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers];
    
    for (UIViewController *vc in marr) {
        
        if ([vc isKindOfClass:NSClassFromString(@"FPLoanController")]) {
            
            [marr removeObject:vc];
            
            break;
        }
    }
    
    for (UIViewController *vc in marr) {
        
        if ([vc isKindOfClass:NSClassFromString(@"FPConfirmLoanContractController")]) {
            
            [marr removeObject:vc];
            
            break;
        }
    }
    
    self.navigationController.viewControllers = marr;
}

- (void)initUI {
    
    [self setTitle:@"借款审核" style:(XYCustomNavigationStyleWhite) hiddenBackBtn:NO];
    self.view.backgroundColor = MAIN_VIEW_BACKGROUND_COLOR;
    
    self.descripLab.textColor = [UIColor hexColor:@"#6A6A6A"];
    
    self.backView.clipsToBounds = YES;
    self.backView.layer.cornerRadius = 8.f;
    
    self.tipLab1.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.tipLab2.textColor = [UIColor hexColor:@"#3A3A3A"];
    self.tipLab3.textColor = [UIColor hexColor:@"#000000"];
    self.tipLab4.textColor = [UIColor hexColor:@"#000000"];
    self.tipLab5.textColor = [UIColor hexColor:@"#000000"];
    self.tipLab6.textColor = [UIColor hexColor:@"#000000"];
    
    self.lineView.backgroundColor = [UIColor hexColor:@"#DEDEDE"];
    
    [self getBankCardInfo];
    
    [self refreshUI];
}

- (void)refreshUI {
    
    [self.bankLogoImgView sd_setImageWithURL:[NSURL URLWithString:self.bankCardImgInfo] placeholderImage:IMG(@"icon_bank_card_default")];
    
    self.tipLab4.text = [self.amountInfo stringByAppendingString:@"元"];
    self.tipLab6.text = self.bankCardInfo;
}

- (void)getBankCardInfo {
    
    [MBManager showLoading];
    [FPBankCardModel getCardListSuccess:^(NSInteger code, NSString * _Nonnull message, NSArray * _Nonnull list) {
        [MBManager hideLoading];
        
        // 刷新银行卡列表
        if (list.count == 0) {
            
        }
        else {
            
            for (FPBankCardModel *model in list) {
                
                if ([model.ID isEqualToString:self.bankCardID]) {
                    
                    self.bankCardInfo = model.bankName;
                }
            }
        }
#warning 未填充 银行卡logo 等信息  这个完善后同步"我的银行卡"控制器
        [self refreshUI];
        
    } failure:^(NSError * _Nonnull error) {
        [self showError:error];
    }];
}





@end


